/**
 * Copyright (c) 2006, PORTALIER Julien
 * 
 * Licensed under The LGPL License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @package    FeatherCMS
 * @subpackage Javascript
 * @copyright  Copyright (c) 2006, Julien PORTALIER
 * @link       http://portalier.com/feather
 * @license    http://www.opensource.org/licenses/lgpl-license.php The LGPL License
 */

Fx.Clip = Fx.Style.extend(
{
	initialize: function (el, options)
	{
		this.parent(el, 'clip', options);
	},
	
	compute: function(from, to)
	{
		var val = [];
		for (var i = 0; i < 4; i++)
			val[i] = this.options.transition(this.cTime, from[i], (to[i] - from[i]), this.options.duration);
		return val;
	},
	
	hide: function()
	{
		return this.set([0, 0, 0, 0]);
	},
	
	show: function()
	{
		return this.set(this.max);
	},
	
	goTo: function(val)
	{
		return this.custom(this.now || [0, 0, 0, 0], val);
	},
	
	increase: function()
	{
		this.element.setStyle(this.property, 'rect(' + this.now.join(this.options.unit + ',') + this.options.unit + ')');
	}
});

Fx.Discover = Fx.Clip.extend(
{
	expand: function()
	{
		return this.custom(this.now || [0, 0, 0, 0], [0, this.element.offsetWidth, this.element.offsetHeight, 0]);
	},
	
	retract: function()
	{
		return this.custom(this.now || [0, this.element.offsetWidth, this.element.offsetHeight, 0], [0, 0, 0, 0]);
	}
});